package com.Li.spring.test;

import com.Li.spring.pojo.Clazz;
import com.Li.spring.pojo.Student;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class testIOC {

    @Test
    public void testIOC(){
        ClassPathXmlApplicationContext ioc = new ClassPathXmlApplicationContext("spring_ioc.xml");
//        Student studentOne = (Student) ioc.getBean("studentOne");
        Student student = ioc.getBean("studentFour", Student.class);//最常用方法
//        Student studentOne = ioc.getBean("studentOne", Student.class);
        System.out.println("student = " + student);
    }

    @Test
    public void testDI(){
        ClassPathXmlApplicationContext ioc = new ClassPathXmlApplicationContext("spring_ioc.xml");
        Clazz clazz = ioc.getBean("clazzOne", Clazz.class);
        System.out.println("clazz = " + clazz);
    }
}
